local oo = require("SharedLibs.BaseLib")
local co = require("SharedLibs.CoroLib")

AsyncOpState = require("SharedLibs.AsyncOpState")
AsyncOp = require("SharedLibs.AsyncOp")

--- An op that will never done!
BlockOp = oo.Class()
BlockOp.name = "DeadOp"
oo.ClassExtends(BlockOp, AsyncOp)

function co.Block(onStopped)
	return co.yield(oo.New(BlockOp, onStopped));
end

function co.NewBlock(onStopped)
	return oo.New(BlockOp, onStopped);
end

function BlockOp.prototype.constructor(self, onStopped)
	BlockOp._ss.prototype.constructor(self)
	self._state = AsyncOpState.Ready
	self._onStopped = onStopped;
end

function BlockOp.prototype:_onStop()
	if self._onStopped then
		self._onStopped();
	end
end

return BlockOp;
